package ps.server.rights;

import ps.util.MD5;


public class User {
    
    public static final int RIGHT_NONE = 0;
    public static final int RIGHT_ADMIN = 1;
    
    String name;
    MD5 authId;
    
    int right = RIGHT_NONE;
    
    public User() {
    }
    
    public User(String name, MD5 authId) {
        this.name = name;
        this.authId = authId;
    }
    
    public User(String name, String pass) {
        this.name = name;
        this.authId = new MD5(MD5.generateAuthId(name, pass));
    }

    @Override
    public String toString() {
        return name;
    }
    
    public String getName() {
        return name;
    }

    
    public void setName(String name) {
        this.name = name;
    }

    
    public MD5 getAuthId() {
        return authId;
    }

    
    public void setAuthId(MD5 authId) {
        this.authId = authId;
    }

    
    public boolean isAdmin() {
        return right == RIGHT_ADMIN;
    }

    
    public void setAdmin(boolean b) {
        this.right = b ? RIGHT_ADMIN : RIGHT_NONE;
    }
    
    public void setRight(int right) {
        this.right = right;
    }
    
    public int getRight() {
        return right;
    }

    
}
